package hy.controller;

import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MyCtrl {
    //在访问时，会要求先认证，默认用户名：user,密码：看控制台
    @RequestMapping("/test")
    public String h(){
        return "success!";
    }

    //登录成功后执行的请示路径
    @RequestMapping("/index")
    public String suc(){
        return "login success!";
    }

    @Secured("ROLE_sale")
    @RequestMapping("/update")
    public String update(){
        return "update success";
    }

    @PreAuthorize("hasAuthority('admins')")
    @RequestMapping("/m1")
    public String m1(){
        return "m1 success";
    }
    @RequestMapping("/logoutSuc")
    public String m2(){
        return "you have logout!";
    }
}
